import Vue from 'vue'
import Vuex from 'vuex'
import createVuexPersisted from 'vuex-persistedstate'
// 子模块引入根模块，产生关联
import user from '@/store/modules/user'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
  },
  getters: {
  },
  mutations: {
  },
  actions: {
  },
  modules: {
    user
  },
  plugins: [
    createVuexPersisted({
      reducer (val) {
        // 指定存储某个模块的数据
        return {
          user: {
            token: val.user.token,
            userId: val.user.userId
          }
        }
      }
    })
  ]
})
